package com.game.centerserver.infrastructure.service.impl;

import com.game.centerserver.infrastructure.entity.User;
import com.game.centerserver.infrastructure.dao.UserDao;
import com.game.centerserver.infrastructure.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2024-11-13 21:32:39
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    /**
     * 通过手机号查询用户
     * @param iphoneNumber
     * @return
     */
    @Override
    public User queryByIphoneNumber(String iphoneNumber) {
        User user = userDao.queryOneByIphoneNumber(iphoneNumber);
        return user;
    }

    /**
     * 通过ID查询单条数据
     *
     * @param uid 主键
     * @return 实例对象
     */
    @Override
    public User queryById(String uid) {
        return this.userDao.queryById(uid);
    }


    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(User user) {
        int insert = this.userDao.insert(user);
        return insert > 0;
    }

    /**
     * 修改数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(User user) {

        return this.userDao.update(user) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param uid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String uid) {
        return this.userDao.deleteById(uid) > 0;
    }

    @Override
    public List<User> getAllUsers() {
        return List.of();
    }
}
